package bai9.service.implement;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import bai9.model.Employee;
import bai9.service.EmployeeAPI;

public class EmployeeDAO implements EmployeeAPI{
	ArrayList<Employee> dsEmp=new ArrayList<Employee>();
	public int addEmployee(Employee emp) {
		dsEmp.add(emp);
		if(dsEmp!=null) return Constan.SER_STATUS_SUCSESS;
		return Constan.SER_STATUS_EROOR;
	}
	public void updateEmployee(Employee emp) {
		Scanner ip=new Scanner(System.in);
		System.out.println("Enter Id you want update: ");
		int id=Integer.parseInt(ip.nextLine());
		for( Employee emp1:dsEmp){
			if(emp.getEmployeeid()==id){
		System.out.println("|Employeeid\t|Name\t\t\t|BirthOfDate\t|Address\t|Gender\t|Salary\t|Username\t|Email\n");
		System.out.println(emp1.getEmployeeid()+"\t"+emp1.getName()+"\t"+emp1.getBirthofdate()+"\t"+emp1.getAddress()+"\t"+emp1.getGender()+"\t"+emp1.getSalary()+"\t"+emp1.getUsername()+"\t"+emp1.getEmail());
		dsEmp.set(id, emp.inputEmployee());
			}
		}
	}
	public int deleteEmployee(Employee emp) {
		// TODO Auto-generated method stub
		return 0;
	}
	public Employee searchEmployee(int id) {
		// TODO Auto-generated method stub
		return null;
	}
	public void display() {
		if(dsEmp!=null){
		System.out.println("============================Danh sach Employee==============================\n");
		System.out.println("|Employeeid\t|Name\t\t\t|BirthOfDate\t|Address\t|Gender\t|Salary\t|Username\t|Email\n");
		for(Employee emp:dsEmp)
		System.out.println(emp.getEmployeeid()+"\t"+emp.getName()+"\t"+emp.getBirthofdate()+"\t"+emp.getAddress()+"\t"+emp.getGender()+"\t"+emp.getSalary()+"\t"+emp.getUsername()+"\t"+emp.getEmail());
		}
		else System.out.println("List Empty");
	}
}
